<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>

  <title>Installing TinyOS 2.0.2</title>
  <link href="../stylesheets/tutorial.css" rel="stylesheet" type="text/css"/>
</head>
  <body>

    <div class="title">Upgrading from TinyOS 1.x to TinyOS 2.0.2</div>
    <div class="subtitle">Last updated 30 July 2007</div>
<p>
This document describes how to upgrade your TinyOS 1.x environment to
a TinyOS 2.x environment. This requires that you not only install the 
TinyOS 2.x rpm, but also that you upgrade your tools from the toolset
distributed with TinyOS 1.1.0 and used with all 1.x
TinyOS versions up through and including TinyOS 1.1.14. The new
toolset was created for use with TinyOS 1.x beyond 1.1.14 as well
as TinyOS 2.x. We call this new tooset version the '1.2' toolset.
</p><p>
Because we expect many developers to maintain a 1.x and 2.x tree
simultaneously, we will also explain what parts of your environment
need to be reconfigured if you switch from TinyOS 2.x to TinyOS
1.x. The 1.2 toolset is backwards compatible with the 1.x TinyOS tree,
so switching back and forth requires only a few variable changes. You
can find those directions <a href="#tinyos1">at the bottom of the page</a>.
</p>
<p>
There are 3 steps to upgrading from 1.x to 2.x:
</p>
<ol>
  <li> <a href="#external-tools">Upgrade your external tools (compilers). </a></li>
  <li> <a href="#tinyos-tools">Upgrade your Tinyos-specific tools. </a></li>
  <li> <a href="#tinyos2">Install the Tinyos 2.x source tree. </a></li>
</ol>


<h1><a name="external-tools">Step 1: Upgrade your external tools.</a></h1>
The 1.2 toolset uses the same Java JDK and ATT Graphviz versions, so 
those do not need to be upgraded. What does need to be upgraded are
your compiler tools. Install the appropriate version of the following 
(Windows or Linux) with the rpm command 'rpm -Uvh <i>rpm</i>'.
<p>
At this time, we have available compiler toolsets for Atmel AVR and 
TI MSP430 platforms. 
</p>
<p>
All of the tools are in the <code>http://www.tinyos.net/dist-1.2.0/</code>
and the <code>http://www.tinyos.net/dist-2.0.0</code>
distribution trees, but are linked below for convenience.
</p>

<b><em>Atmel AVR Tools</em></b>
<table border="0">
<tbody><tr>
  <td bgcolor="#dddddd"><b>Tool</b></td>
  <td bgcolor="#dddddd"><b>Windows/Cygwin</b></td>
  <td bgcolor="#dddddd"><b>Linux</b></td>
</tr>

<tr>
  <td>avr-binutils<font color="red">&#8224;</font></td>
  <td><a href="http://www.tinyos.net/dist-2.0.0/tools/windows/avr-binutils-2.15tinyos-3.cygwin.i386.rpm">avr-binutils-2.15tinyos-3.cygwin.i386.rpm</a></td>
  <td><a href="http://www.tinyos.net/dist-2.0.0/tools/linux/avr-binutils-2.15tinyos-3.i386.rpm">avr-binutils-2.15tinyos-3.i386.rpm</a></td>
</tr>

<tr>
  <td bgcolor="#dddddd">avr-gcc</td>
  <td bgcolor="#dddddd"><a href="http://www.tinyos.net/dist-2.0.0/tools/windows/avr-gcc-3.4.3-1.cygwin.i386.rpm">avr-gcc-3.4.3-1.cygwin.i386.rpm </a></td>
  <td bgcolor="#dddddd"><a href="http://www.tinyos.net/dist-2.0.0/tools/linux/avr-gcc-3.4.3-1.i386.rpm">avr-gcc-3.4.3-1.i386.rpm</a></td>
</tr>

<tr>
  <td>avr-libc</td>
  <td><a href="http://www.tinyos.net/dist-2.0.0/tools/windows/avr-libc-1.2.3-1.cygwin.i386.rpm">avr-libc-1.2.3-1.cygwin.i386.rpm</a></td>
  <td><a href="http://www.tinyos.net/dist-2.0.0/tools/linux/avr-libc-1.2.3-1.i386.rpm">avr-libc-1.2.3-1.i386.rpm</a></td>
</tr>

<tr>
  <td bgcolor="#dddddd">avarice</td>
  <td bgcolor="#dddddd"><a href="http://www.tinyos.net/dist-2.0.0/tools/windows/avarice-2.4-1.cygwin.i386.rpm">avarice-2.4-1.cygwin.i386.rpm</a></td>
  <td bgcolor="#dddddd"><a href="http://www.tinyos.net/dist-2.0.0/tools/linux/avarice-2.4-1.i386.rpm">avarice-2.4-1.i386.rpm</a></td>
</tr>

<tr>
  <td bgcolor="#dddddd">insight (avr-gdb)</td>
  <td bgcolor="#dddddd"><a href="http://www.tinyos.net/dist-1.2.0/tools/windows/avr-insight-6.3-1.cygwin.i386.rpm">avr-insight-6.3-1.cygwin.i386.rpm</a></td>
  <td bgcolor="#dddddd"><a href="http://www.tinyos.net/dist-2.0.0/tools/linux/avr-insight-6.3-1.i386.rpm">avr-insight-6.3-1.i386.rpm</a></td>
</tr>

</tbody></table>
<i><font color="red">&#8224;</font>If you receive an rpm error that indicates that you have a newer version already installed, try <code>rpm -Uvh --force</code></i>

<p></p>
<b><em>TI MSP430 Tools</em></b>
<table border="0">
<tbody><tr>
  <td bgcolor="#dddddd"><b>Tool</b></td>
  <td bgcolor="#dddddd"><b>Windows/Cygwin</b></td>
  <td bgcolor="#dddddd"><b>Linux</b></td>
</tr>

<tr>
  <td>base</td>
  <td><a href="http://www.tinyos.net/dist-2.0.0/tools/windows/msp430tools-base-0.1-20050607.cygwin.i386.rpm">msp430tools-base-0.1-20050607.cygwin.i386.rpm</a></td>
  <td><a href="http://www.tinyos.net/dist-2.0.0/tools/linux/msp430tools-base-0.1-20050607.i386.rpm">msp430tools-base-0.1-20050607.i386.rpm</a></td>
</tr>

<tr>
  <td bgcolor="#dddddd">python tools</td>
  <td bgcolor="#dddddd"><a href="http://www.tinyos.net/dist-2.0.0/tools/windows/msp430tools-python-tools-1.0-1.cygwin.noarch.rpm">msp430tools-python-tools-1.0-1.cygwin.noarch.rpm</a></td>
  <td bgcolor="#dddddd"><a href="http://www.tinyos.net/dist-2.0.0/tools/linux/msp430tools-python-tools-1.0-1.noarch.rpm">msp430tools-python-tools-1.0-1.noarch.rpm</a></td>
</tr>


<tr>
  <td>binutils</td>
  <td><a href="http://www.tinyos.net/dist-2.0.0/tools/windows/msp430tools-binutils-2.16-20050607.cygwin.i386.rpm"> msp430tools-binutils-2.16-20050607.cygwin.i386.rpm</a></td>
  <td><a href="http://www.tinyos.net/dist-2.0.0/tools/linux/msp430tools-binutils-2.16-20050607.i386.rpm">msp430tools-binutils-2.16-20050607.i386.rpm</a></td>
</tr>

<tr>
  <td bgcolor="#dddddd">gcc</td>
  <td bgcolor="#dddddd"><a href="http://www.tinyos.net/dist-2.0.0/tools/windows/msp430tools-gcc-3.2.3-20050607.cygwin.i386.rpm">msp430tools-gcc-3.2.3-20050607.cygwin.i386.rpm</a></td>
  <td bgcolor="#dddddd"><a href="http://www.tinyos.net/dist-2.0.0/tools/linux/msp430tools-gcc-3.2.3-20050607.i386.rpm">msp430tools-gcc-3.2.3-20050607.i386.rpm</a></td>
</tr>

<tr>
  <td>libc</td>
  <td><a href="http://www.tinyos.net/dist-2.0.0/tools/windows/msp430tools-libc-20050308cvs-20050608.cygwin.i386.rpm">msp430tools-libc-20050308cvs-20050608.cygwin.i386.rpm</a></td>
  <td><a href="http://www.tinyos.net/dist-2.0.0/tools/linux/msp430tools-libc-20050308cvs-20050608.i386.rpm">msp430tools-libc-20050308cvs-20050608.i386.rpm</a></td>
</tr>

<tr>
  <td bgcolor="#dddddd">jtag</td>
  <td bgcolor="#dddddd"><a href="http://www.tinyos.net/dist-2.0.0/tools/windows/"></a>Not yet available</td>
  <td bgcolor="#dddddd"><a href="http://www.tinyos.net/dist-2.0.0/tools/linux/msp430tools-jtag-lib-20031101cvs-20050610.i386.rpm">msp430tools-jtag-lib-20031101cvs-20050610.i386.rpm</a></td>
</tr>

<tr>
  <td>gdb</td>
  <td><a href="http://www.tinyos.net/dist-2.0.0/tools/windows/"></a>Not yet available</td>
  <td><a href="http://www.tinyos.net/dist-2.0.0/tools/linux/msp430tools-gdb-6.0-20050609.i386.rpm">msp430tools-gdb-6.0-20050609.i386.rpm</a></td>
</tr>

</tbody></table>

<h1><a name="tinyos-tools">Step 2: Upgrade your TinyOS-specific tools.</a></h1>

<p>
The TinyOS-specific tools are the NesC compiler and a set of tools
developed in the tinyos-2.x/tools source code repository. They are
also installed using rpms. Due to file conflicts between the new version
of the tinyos-tools and older NesC installations, you must upgrade
your NesC installation before you upgrade tinyos-tools. 
Also, if you plan on maintaining a tinyos-1.x tree 
simultaneously with a tinyos-2.x tree, the tinyos-tools installed for the
1.x versions must remain installed so use <code>rpm -ivh</code>. If you are 
only installing a 2.x tree, you can use <code>rpm -Uvh</code>.
If you using the Cygwin version recommended
in these install
instructions, you should install the "Recommended" Windows/Cygwin
nesC RPM.
If you
get strange errors when you try to compile TinyOS programs,
such as the error message "the procedure entry point basename could not be located
in the dynamic link library cygwin1.dll", this is likely due
to a Cygwin version incompatibility: try the "Other" Windows/Cygwin 
RPM. If you are using Cygwin and installing the nesC RPM 
causes an error that the RPM was built for Cygwin, add the <tt>--ignoreos</tt>
option.
</p>

<b><em>TinyOS-specific Tools</em></b>
<table border="0">
<tbody><tr>
  <td bgcolor="#dddddd"><b>Tool</b></td>
  <td bgcolor="#dddddd"><b>Recommended Windows/Cygwin</b></td>
  <td bgcolor="#dddddd"><b>Other Windows/Cygwin</b></td>
  <td bgcolor="#dddddd"><b>Linux</b></td>
  <td bgcolor="#dddddd"><b>Command</b></td>
</tr>

<tr>
  <td>NesC</td>
  <td><a href="http://www.tinyos.net/dist-1.2.0/tinyos/windows/nesc-1.2.8a-1.cygwin.i386.rpm">nesc-1.2.8a-1.cygwin.i386.rpm</a></td>
  <td><a href="http://www.tinyos.net/dist-1.2.0/tinyos/windows/nesc-1.2.8b-1.cygwin.i386.rpm">nesc-1.2.8b-1.cygwin.i386.rpm</a></td>
  <td><a href="http://www.tinyos.net/dist-1.2.0/tinyos/linux/nesc-1.2.8a-1.i386.rpm">nesc-1.2.8a-1.i386.rpm </a></td>
  <td><a href=""></a><code>rpm -Uvh</code><br/><code>rpm -Uvh --ignoreos</code> (if Cygwin complains)</td>
</tr>

<tr>
  <td bgcolor="#dddddd"><b>Tool</b></td>
  <td bgcolor="#dddddd"><b>Windows/Cygwin</b></td>
  <td bgcolor="#dddddd"><b>32-bit Linux</b></td>
  <td bgcolor="#dddddd"><b>64-bit Linux</b></td>
  <td bgcolor="#dddddd"><b>Command</b></td>
</tr>

<tr>
  <td>tinyos-tools</td>
  <td><a href="http://www.tinyos.net/dist-2.0.0/tinyos/windows/tinyos-tools-1.2.4-2.cygwin.i386.rpm">tinyos-tools-1.2.4-2.cygwin.i386.rpm</a></td>
  <td><a href="http://www.tinyos.net/dist-2.0.0/tinyos/linux/tinyos-tools-1.2.4-3.i386.rpm">tinyos-tools-1.2.4-3.i386.rpm</a></td>
  <td><a href="http://www.tinyos.net/dist-2.0.0/tinyos/linux/tinyos-tools-1.2.4-3.i686.rpm">tinyos-tools-1.2.4-3.i686.rpm</a></td>
  <td><a href=""></a><code>rpm -ivh --force</code>&nbsp;(1.x tree)<br><code>rpm -Uvh</code>&nbsp;(no 1.x tree)<br></td>
</tr>

</tbody></table>

<h1><a name="tinyos2">Step 3: Install the TinyOS 2.x source tree.</a></h1>

Now that the tools are installed, you need only install the tinyos 2.x 
source tree and then set your environment variables.

<ul>
<li> Install tinyos-2.x

<p>If you have an existing 1.x tree, we strongly recommend that you use
the install (<code>-i</code>) rpm argument when installing the tinyos-2.x rpm rather 
than the upgrade (<code>-U</code>) argument. The difference is that the <code>-U</code> will 
first remove the tinyos-1.x tree while <code>-i</code> will not remove previously installed
files. Said another way, we recommend using <code>rpm -ivh</code>.</p>

<p>If you have an existing 2.x tree which you want to keep unchanged, then
you will need to move it to make space for the new one. For example, if you
have an existing tree in <tt>/opt/tinyos-2.x/</tt>, then you can move it
to <tt>/opt/tinyos-2.x-old</tt>. Once you have moved it, we recommend
performing a forced installation of the 2.0 tree.</p>

<p>If you have an existing 2.x tree which you do not care about, then we
recommend removing it before installing the new one with a forced install.</p>

<b><em>TinyOS 2.x</em></b>
<table border="0">
<tbody><tr>
  <td bgcolor="#dddddd"><b></b></td>
  <td bgcolor="#dddddd"><b>Windows/Cygwin</b></td>
  <td bgcolor="#dddddd"><b>Linux</b></td>
  <td bgcolor="#dddddd"><b>Command</b></td>
</tr>

<tr>
  <td>TinyOS</td>
  <td><a href="http://www.tinyos.net/dist-2.0.0/tinyos/windows/tinyos-2.0.2-2.cygwin.noarch.rpm">tinyos-2.0.2-2.cygwin.noarch.rpm</a></td>
  <td><a href="http://www.tinyos.net/dist-2.0.0/tinyos/linux/tinyos-2.0.2-2.noarch.rpm">tinyos-2.0.2-2.noarch.rpm</a></td>
  <td><tt>rpm -Uvh</tt> (to upgrade)<br/>
      <tt>rpm -ivh</tt> (to install)<br/>
      <tt>rpm -ivh --force</tt> (to force install)<br/>
  </td>      
</tr>

</tbody></table></li>

<li> Configure your environment
<p>
In TinyOS 1.x, much of your environment was set by the rpm installation process
by copying a tinyos.sh file into /etc/profile.d which was subsequently run anytime
a shell was started. Because this was deemed unnecessarily invasive, the 2.x rpm
does not do this. Rather, you need to set these variables yourself. Ideally, you'll
put them in a shell script that will run when your shell starts, but you needn't 
put such a script under /etc/profile.d. 
</p>
<p>
<i>Please take note of the current settings since you'll need those if you want
to work in your current 1.x tree sometime in the future. </i>
</p>
<p>
The example
settings below assume that the tinyos-2.x installation is in /opt/tinyos-2.x.
Change the settings to be correct for where you've put your tinyos-2.x tree. Note
that the windows CLASSPATH must be a windows-style path, not a cygwin path. You can 
generate a windows style path from a cygwin-style path using 'cygpath -w'. For example:
</p>
<pre>export CLASSPATH=`cygpath -w $TOSROOT/support/sdk/java/tinyos.jar`
export CLASSPATH="$CLASSPATH;."
</pre>

<p></p><b><em>TinyOS 2.x</em></b>
<table border="0">
<tbody><tr>
  <td bgcolor="#dddddd"><b>Environment Variable</b></td>
  <td bgcolor="#dddddd"><b>Windows</b></td>
  <td bgcolor="#dddddd"><b>Linux</b></td>
</tr>

<tr>
  <td>TOSROOT</td>
  <td>/opt/tinyos-2.x</td>
  <td>same as in Cygwin</td>
<td>

</td></tr><tr>
  <td bgcolor="#dddddd">TOSDIR</td>
  <td bgcolor="#dddddd">$TOSROOT/tos</td>
  <td bgcolor="#dddddd">same as in Cygwin</td>
<td>

</td></tr><tr>
  <td>CLASSPATH</td>
  <td>C:\tinyos\cygwin\opt\tinyos-2.x\support\sdk\java\tinyos.jar;.</td>
  <td>$TOSROOT/support/sdk/java/tinyos.jar:.</td>
<td>

</td></tr><tr>
  <td bgcolor="#dddddd">MAKERULES</td>
  <td bgcolor="#dddddd">$TOSROOT/support/make/Makerules</td>
  <td bgcolor="#dddddd">same as in Cygwin</td>
<td>

</td></tr><tr>
  <td>PATH<font color="red">&#8224;</font></td>
  <td>/opt/msp430/bin:$PATH</td>
  <td>same as in Cygwin</td>
<td>

</td></tr></tbody></table>

<i><font color="red">&#8224;</font>Only necessary if you're using the MSP430 platform/tools.</i>

<p>
In addition to the above environment variables, do the following on Linux machines:
</p>

<ol>
<li> Change the ownership on your /opt/tinyos-2.x files: <code>chown -R&nbsp;&lt;your uid&gt;&nbsp;/opt/tinyos-2.x
</code></li>
<li> Change the permissions on any serial (/dev/ttyS&lt;N&gt;), usb
(/dev/tts/usb&lt;N&gt;, /dev/ttyUSB&lt;N&gt;), or parallel (/dev/parport) devices you
are going to use: <code>chmod 666 /dev/&lt;devicename&gt;</code></li>
</ol></li>
</ul>

<ul>
<li><p>Finally, if you have installed TinyOS 2.0.1, there is a bug in TOSSIM (which will be fixed in 2.0.2).
The bug is in file <tt>tos/chips/atm128/sim/atm128_sim.h</tt>. Change these lines 22 and 23 from:</p>

<pre>
#define _SFR_IO8(io_addr) _MMIO_BYTE((io_addr) + 0x20)
#define _SFR_IO16(io_addr) _MMIO_WORD((io_addr) + 0x20)
</pre>

<p>to</p>

<pre>
#define _SFR_IO8(io_addr) _MMIO_BYTE((io_addr))
#define _SFR_IO16(io_addr) _MMIO_WORD((io_addr))
</pre>

<p>If you do not do this, then timers will not work correctly.</p>
</li>
</ul>

<h1><a name="tinyos1">Switching back to a TinyOS 1.x tree</a></h1>
<p>Since the tools are backwardly compatible, you need only change
your environment variables to point to the 1.x settings. Assuming 
that your old tree was in /opt/tinyos-1.x, you would use the following 
values:
</p>

<b><em>TinyOS 1.x</em></b>
<table border="0">
<tbody><tr>
  <td bgcolor="#dddddd"><b>Environment Variable</b></td>
  <td bgcolor="#dddddd"><b>Windows</b></td>
  <td bgcolor="#dddddd"><b>Linux</b></td>
</tr>

<tr>
  <td>TOSROOT</td>
  <td>/opt/tinyos-1.x</td>
  <td>same as in Cygwin</td>
<td>

</td></tr><tr>
  <td bgcolor="#dddddd">TOSDIR</td>
  <td bgcolor="#dddddd">$TOSROOT/tos</td>
  <td bgcolor="#dddddd">same as in Cygwin</td>
<td>

</td></tr><tr>
  <td>CLASSPATH</td>
  <td>`$TOSROOT/tools/java/javapath`</td>
  <td>same as in Cygwin</td>
<td>

</td></tr><tr>
  <td bgcolor="#dddddd">MAKERULES</td>
  <td bgcolor="#dddddd">$TOSROOT/tools/make/Makerules</td>
  <td bgcolor="#dddddd">same as in Cygwin</td>
<td>

</td></tr></tbody></table>

<p>Switching between the two should require switching only these environment
variables.</p>
</body></html>
